home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Kernel.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  29KB  |  866 lines

  1. /*
  2.      File:        Kernel.h
  3.  
  4.      Contains:    Kernel Interfaces
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __KERNEL__
  19. #define __KERNEL__
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. #ifndef __MACHINEEXCEPTIONS__
  25. #include <MachineExceptions.h>
  26. #endif
  27. #ifndef __TIMING__
  28. #include <Timing.h>
  29. #endif
  30. #ifndef __TYPES__
  31. #include <Types.h>
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT_SUPPORTED
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_ALIGN_SUPPORTED
  43. #pragma options align=power
  44. /* the following contents can only be used by compilers that support PowerPC struct alignment */
  45.  
  46. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  47. /* Kernel basics*/
  48. typedef struct OpaqueAddressSpaceID* AddressSpaceID;
  49. typedef struct OpaqueIOPreparationID* IOPreparationID;
  50. typedef struct OpaqueSoftwareInterruptID* SoftwareInterruptID;
  51. typedef struct OpaqueTaskID* TaskID;
  52. typedef struct OpaqueTimerID* TimerID;
  53. /* Tasking*/
  54. typedef UInt32 ExecutionLevel;
  55.  
  56. enum {
  57.     kTaskLevel                    = 0,
  58.     kSoftwareInterruptLevel        = 1,
  59.     kAcceptFunctionLevel        = 2,
  60.     kKernelLevel                = 3,
  61.     kSIHAcceptFunctionLevel        = 4,
  62.     kSecondaryInterruptLevel    = 5,
  63.     kHardwareInterruptLevel        = 6
  64. };
  65.  
  66. typedef void (*SoftwareInterruptHandler)(void *p1, void *p2);
  67. typedef OSStatus (*SecondaryInterruptHandler2)(void *p1, void *p2);
  68. /* Memory System basics*/
  69. struct LogicalAddressRange {
  70.     LogicalAddress                     address;
  71.     ByteCount                         count;
  72. };
  73. typedef struct LogicalAddressRange LogicalAddressRange;
  74.  
  75. typedef LogicalAddressRange *LogicalAddressRangePtr;
  76. struct PhysicalAddressRange {
  77.     PhysicalAddress                 address;
  78.     ByteCount                         count;
  79. };
  80. typedef struct PhysicalAddressRange PhysicalAddressRange;
  81.  
  82. typedef PhysicalAddressRange *PhysicalAddressRangePtr;
  83. /* For PrepareMemoryForIO and CheckpointIO*/
  84. typedef OptionBits IOPreparationOptions;
  85.  
  86. enum {
  87.     kIOMultipleRanges            = 0x00000001,
  88.     kIOLogicalRanges            = 0x00000002,
  89.     kIOMinimalLogicalMapping    = 0x00000004,
  90.     kIOShareMappingTables        = 0x00000008,
  91.     kIOIsInput                    = 0x00000010,
  92.     kIOIsOutput                    = 0x00000020,
  93.     kIOCoherentDataPath            = 0x00000040,
  94.     kIOTransferIsLogical        = 0x00000080,
  95.     kIOClientIsUserMode            = 0x00000080
  96. };
  97.  
  98. typedef OptionBits IOPreparationState;
  99.  
  100. enum {
  101.     kIOStateDone                = 0x00000001
  102. };
  103.  
  104.  
  105. enum {
  106.     kInvalidPageAddress            = (-1)
  107. };
  108.  
  109. struct AddressRange {
  110.     void *                            base;
  111.     ByteCount                         length;
  112. };
  113. typedef struct AddressRange AddressRange;
  114.  
  115. /* C's treatment of arrays and array pointers is atypical*/
  116. typedef LogicalAddress *LogicalMappingTablePtr;
  117. typedef PhysicalAddress *PhysicalMappingTablePtr;
  118. typedef AddressRange *AddressRangeTablePtr;
  119. struct MultipleAddressRange {
  120.     ItemCount                         entryCount;
  121.     AddressRangeTablePtr             rangeTable;
  122. };
  123. typedef struct MultipleAddressRange MultipleAddressRange;
  124.  
  125. /*
  126.  Separate C definition so that union has a name.  A future version of the interfacer
  127.  tool will allow a name (that gets thrown out in Pascal and Asm).
  128. */
  129. struct IOPreparationTable {
  130.     IOPreparationOptions             options;
  131.     IOPreparationState                 state;
  132.     IOPreparationID                 preparationID;
  133.     AddressSpaceID                     addressSpace;
  134.     ByteCount                         granularity;
  135.     ByteCount                         firstPrepared;
  136.     ByteCount                         lengthPrepared;
  137.     ItemCount                         mappingEntryCount;
  138.     LogicalMappingTablePtr             logicalMapping;
  139.     PhysicalMappingTablePtr         physicalMapping;
  140.     union {
  141.         AddressRange                     range;
  142.         MultipleAddressRange             multipleRanges;
  143.     }                                 rangeInfo;
  144. };
  145. typedef struct IOPreparationTable IOPreparationTable;
  146.  
  147. typedef OptionBits IOCheckpointOptions;
  148.  
  149. enum {
  150.     kNextIOIsInput                = 0x00000001,
  151.     kNextIOIsOutput                = 0x00000002,
  152.     kMoreIOTransfers            = 0x00000004
  153. };
  154.  
  155. /* For SetProcessorCacheMode*/
  156. typedef UInt32 ProcessorCacheMode;
  157.  
  158. enum {
  159.     kProcessorCacheModeDefault    = 0,
  160.     kProcessorCacheModeInhibited = 1,
  161.     kProcessorCacheModeWriteThrough = 2,
  162.     kProcessorCacheModeCopyBack    = 3
  163. };
  164.  
  165. /* For GetPageInformation*/
  166.  
  167. enum {
  168.     kPageInformationVersion        = 1
  169. };
  170.  
  171. typedef UInt32 PageStateInformation;
  172.  
  173. enum {
  174.     kPageIsProtected            = 0x00000001,
  175.     kPageIsProtectedPrivileged    = 0x00000002,
  176.     kPageIsModified                = 0x00000004,
  177.     kPageIsReferenced            = 0x00000008,
  178.     kPageIsLockedResident        = 0x00000010,
  179.     kPageIsInMemory                = 0x00000020,
  180.     kPageIsShared                = 0x00000040,
  181.     kPageIsWriteThroughCached    = 0x00000080,
  182.     kPageIsCopyBackCached        = 0x00000100,
  183.     kPageIsLocked                = kPageIsLockedResident,        /* Deprecated*/
  184.     kPageIsResident                = kPageIsInMemory                /* Deprecated*/
  185. };
  186.  
  187. struct PageInformation {
  188.     AreaID                             area;
  189.     ItemCount                         count;
  190.     PageStateInformation             information[1];
  191. };
  192. typedef struct PageInformation PageInformation;
  193.  
  194. typedef PageInformation *PageInformationPtr;
  195. #endif
  196. #if FOR_SYSTEM8_PREEMPTIVE
  197. typedef struct OpaqueAreaReservationID* AreaReservationID;
  198. typedef struct OpaqueBackingObjectID* BackingObjectID;
  199. typedef struct OpaqueEventGroupID* EventGroupID;
  200. typedef struct OpaqueMessageID* MessageID;
  201. typedef struct OpaqueObjectID* ObjectID;
  202. typedef struct OpaquePortID* PortID;
  203. typedef struct OpaqueReceiveID* ReceiveID;
  204. typedef struct OpaqueKernelProcessID* KernelProcessID;
  205. typedef struct OpaqueKernelQueueID* KernelQueueID;
  206. /*  System Information  */
  207.  
  208. enum {
  209.     kSystemInformationVersion    = 1
  210. };
  211.  
  212. struct SystemInformation {
  213.     ItemCount                         numPhysicalRAMPages;
  214.     ItemCount                         numFreeRAMPages;
  215.     ItemCount                         numEligibleRAMPages;
  216.     ItemCount                         numResidentRAMPages;
  217.     ItemCount                         numInMemoryGlobalPages;
  218.     ItemCount                         numLogicalPages;
  219.     ByteCount                         pageSize;
  220.     ByteCount                         dataCacheBlockSize;
  221.     UInt32                             processorVersionNumber;
  222.     ItemCount                         numCPUs;
  223.     KernelProcessID                 systemKernelProcessID;
  224.     AddressSpaceID                     globalAddressSpaceID;
  225.     ByteCount                         dataCacheSize;
  226.     ByteCount                         instructionCacheSize;
  227.     Boolean                         cachesAreUnified;
  228.     SInt8                             filler[3];
  229. };
  230. typedef struct SystemInformation SystemInformation;
  231.  
  232. typedef SystemInformation *SystemInformationPtr;
  233. /*  KernelQueue Related Declarations  */
  234. typedef OptionBits KernelQueueOptions;
  235. /*  Event Flag Related Declarations  */
  236. typedef UInt32 EventGroupMask;
  237.  
  238. enum {
  239.     kEventFlagsPerGroup            = 32
  240. };
  241.  
  242. typedef UInt32 EventFlagOperation;
  243.  
  244. enum {
  245.     kEventFlagAll                = 0,
  246.     kEventFlagAny                = 1,
  247.     kEventFlagAllClear            = 2,
  248.     kEventFlagAnyClear            = 3,
  249.     kEventFlagSharedClear        = 4
  250. };
  251.  
  252. struct KernelNotification {
  253.     EventGroupID                     eventGroup;
  254.     EventGroupMask                     eventMask;
  255.     SoftwareInterruptID             swi;
  256.     KernelQueueID                     kernelQueue;
  257.     void *                            queueP1;
  258.     void *                            queueP2;
  259. };
  260. typedef struct KernelNotification KernelNotification;
  261.  
  262. typedef KernelNotification *KernelNotificationPtr;
  263. /*  Task Related Declarations  */
  264. typedef OSType KernelProcessName;
  265. typedef OSType TaskName;
  266. typedef OSStatus (*TaskProc)(void *parameter);
  267. typedef UInt32 TaskStorageIndex;
  268. typedef void *TaskStorageValue;
  269. typedef UInt32 TaskRelationship;
  270.  
  271. enum {
  272.     kTaskOnly                    = 0,
  273.     kTaskAndChildren            = 1,
  274.     kTaskFamily                    = 2,
  275.     kTaskKernelProcess            = 3
  276. };
  277.  
  278. typedef OptionBits SetTaskPriorityOptions;
  279.  
  280. enum {
  281.     kTaskRaisePriorityBy        = 0x00000200,
  282.     kTaskLowerPriorityBy        = 0x00000400,
  283.     kTaskRaisePriorityToAtLeast    = 0x00000800,
  284.     kTaskLowerPriorityToAtMost    = 0x00001000
  285. };
  286.  
  287. typedef OptionBits TaskOptions;
  288.  
  289. enum {
  290.     kTaskIsOrphan                = 0x00400000,
  291.     kTaskIsResident                = 0x00004000
  292. };
  293.  
  294. /* Priorities are used by CreateTask, SetTaskPriority, and AcceptMessage. */
  295. typedef OptionBits TaskPriority;
  296.  
  297. enum {
  298.     kTaskPriorityMask            = 0x0000001F,
  299.     kTaskPriorityIsAbsolute        = 0x00000100,
  300.     kTaskPriorityIsSymbolic        = 0x00002000,
  301.     kTaskBackgroundPriority        = 0x00002001,                    /* Gets only otherwise idle time*/
  302.     kTaskAppCPUBoundPriority    = 0x00002002,                    /* For CPU bound tasks*/
  303.     kTaskAppNonUIPriority        = 0x00002003,                    /* For general secondary tasks*/
  304.     kTaskAppPriority            = 0x00002004,                    /* Primary tasks*/
  305.     kTaskUIHelperPriority        = 0x00002005,                    /* Toolbox helper tasks*/
  306.     kTaskLowServerPriority        = 0x00002006,                    /* System servers*/
  307.     kTaskServerPriority            = 0x00002007,                    /* System serverss*/
  308.     kTaskHighServerPriority        = 0x00002008,                    /* System servers*/
  309.     kTaskLowDriverPriority        = 0x00002009,                    /* IO Families & plug-ins*/
  310.     kTaskDriverPriority            = 0x0000200A,                    /* IO Families & plug-ins*/
  311.     kTaskHighDriverPriority        = 0x0000200B,                    /* IO Families & plug-ins*/
  312.     kTaskRealTimePriority1        = 0x0000200C,                    /* Lowest real time priority*/
  313.     kTaskRealTimePriority2        = 0x0000200D,
  314.     kTaskRealTimePriority3        = 0x0000200E,
  315.     kTaskRealTimePriority4        = 0x0000200F,
  316.     kTaskRealTimePriority5        = 0x00002010,
  317.     kTaskRealTimePriority6        = 0x00002011,
  318.     kTaskRealTimePriority7        = 0x00002012,
  319.     kTaskRealTimePriority8        = 0x00002013,
  320.     kTaskRealTimePriority9        = 0x00002014,
  321.     kTaskRealTimePriority10        = 0x00002015,
  322.     kTaskRealTimePriority11        = 0x00002016,
  323.     kTaskRealTimePriority12        = 0x00002017,
  324.     kTaskRealTimePriority13        = 0x00002018,
  325.     kTaskRealTimePriority14        = 0x00002019,
  326.     kTaskRealTimePriority15        = 0x0000201A,
  327.     kTaskRealTimePriority16        = 0x0000201B                    /* Highest real time priority*/
  328. };
  329.  
  330. typedef OptionBits TerminateOptions;
  331. typedef OSType SchedulerState;
  332.  
  333. enum {
  334.     kTaskInformationVersion        = 1
  335. };
  336.  
  337. struct TaskInformation {
  338.     TaskName                         name;
  339.     KernelProcessID                 owningKernelProcess;
  340.     TaskOptions                     options;                    /* Includes originally specified symbolic priority*/
  341.     TaskPriority                     priority;                    /* Absolute priority*/
  342.     SchedulerState                     taskState;
  343.     SchedulerState                     swiState;
  344.     Boolean                         isTerminating;
  345.     Boolean                         reserved2[3];
  346.     ItemCount                         softwareInterrupts;
  347.     LogicalAddress                     stackLimit;
  348.     ByteCount                         stackSize;
  349.     AbsoluteTime                     creationTime;
  350.     AbsoluteTime                     cpuTime;
  351.     void *                            reserved;
  352. };
  353. typedef struct TaskInformation TaskInformation;
  354.  
  355. typedef TaskInformation *TaskInformationPtr;
  356. typedef OptionBits KernelProcessOptions;
  357.  
  358. enum {
  359.     kKernelProcessIsPrivileged    = 0x00000001
  360. };
  361.  
  362.  
  363. enum {
  364.     kKernelProcessInformationVersion = 1
  365. };
  366.  
  367. struct KernelProcessInformation {
  368.     KernelProcessName                 name;
  369.     AddressSpaceID                     addressSpace;
  370.     KernelProcessOptions             options;
  371. };
  372. typedef struct KernelProcessInformation KernelProcessInformation;
  373.  
  374. typedef KernelProcessInformation *KernelProcessInformationPtr;
  375. /* Timer related declarations */
  376. typedef OptionBits TimerOptions;
  377. /*  Address Space Management related declarations  */
  378. /* General definitions*/
  379. #define kNoBackingObjectID    ((BackingObjectID) kInvalidID)
  380. typedef OptionBits AreaOptions;
  381.  
  382. enum {
  383.     kZeroFill                    = 0x00000001,
  384.     kResidentArea                = 0x00000002,
  385.     kSparseArea                    = 0x00000004,
  386.     kPlacedArea                    = 0x00000008,
  387.     kGlobalArea                    = 0x00000010,
  388.     kPhysicallyContiguousArea    = 0x00000020,
  389.     kMassMappedArea                = 0x00000040
  390. };
  391.  
  392. typedef OptionBits InterspaceCopyOptions;
  393.  
  394. enum {
  395.     kCheckSourceUserRights        = 0x00000001,
  396.     kCheckDestinationUserRights    = 0x00000002
  397. };
  398.  
  399. typedef UInt32 AreaUsage;
  400.  
  401. enum {
  402.     kUsageUnknown                = 0,
  403.     kUsageRAM                    = 1,
  404.     kUsageROM                    = 2,
  405.     kUsageIO                    = 3,
  406.     kUsageVideoRAM                = 4
  407. };
  408.  
  409. typedef UInt32 MemoryAccessLevel;
  410.  
  411. enum {
  412.     kMemoryExcluded                = 0,
  413.     kMemoryReadOnly                = 1,
  414.     kMemoryReadWrite            = 2,
  415.     kMemoryCopyOnWrite            = 3,
  416.     kInheritUserAccess            = 4,
  417.     kInheritPrivilegedAccess    = 5
  418. };
  419.  
  420. typedef UInt64 BackingAddress;
  421. typedef UInt64 BackingLength;
  422. /*    For GetSpaceInformation*/
  423.  
  424. enum {
  425.     kSpaceInformationVersion    = 1
  426. };
  427.  
  428. struct SpaceInformation {
  429.     ItemCount                         numLogicalPages;
  430.     ItemCount                         numInMemoryPages;
  431.     ItemCount                         numResidentPages;
  432. };
  433. typedef struct SpaceInformation SpaceInformation;
  434.  
  435. typedef SpaceInformation *SpaceInformationPtr;
  436. /*    For GetAreaInformation*/
  437.  
  438. enum {
  439.     kAreaInformationVersion        = 1
  440. };
  441.  
  442. struct AreaInformation {
  443.     AddressSpaceID                     addressSpace;
  444.     LogicalAddress                     base;
  445.     ByteCount                         length;
  446.     MemoryAccessLevel                 userAccessLevel;
  447.     MemoryAccessLevel                 privilegedAccessLevel;
  448.     AreaUsage                         usage;
  449.     BackingObjectID                 backingObject;
  450.     BackingAddress                     backingBase;
  451.     AreaOptions                     options;
  452.     KernelProcessID                 owningKernelProcess;
  453. };
  454. typedef struct AreaInformation AreaInformation;
  455.  
  456. typedef AreaInformation *AreaInformationPtr;
  457. /*    For Memory Reservations*/
  458. typedef OptionBits ReservationOptions;
  459.  
  460. enum {
  461.     kPlacedReservation            = 0x00000001,
  462.     kGlobalReservation            = 0x00000002,
  463.     kGlobalAreaReservation        = 0x00000004
  464. };
  465.  
  466. /*    For GetReservationInformation*/
  467.  
  468. enum {
  469.     kReservationInformationVersion = 1
  470. };
  471.  
  472. struct ReservationInformation {
  473.     AddressSpaceID                     addressSpace;
  474.     LogicalAddress                     base;
  475.     ByteCount                         length;
  476.     ReservationOptions                 options;
  477. };
  478. typedef struct ReservationInformation ReservationInformation;
  479.  
  480. typedef ReservationInformation *ReservationInformationPtr;
  481. /*    For ControlPagingForRange*/
  482. typedef UInt32 PageControlOperation;
  483.  
  484. enum {
  485.     kControlPageMakePageable    = 1,
  486.     kControlPageMakeResident    = 2,
  487.     kControlPageCommit            = 3,
  488.     kControlPageTouch            = 4,
  489.     kControlPageReplace            = 5,
  490.     kControlPageFlush            = 6,
  491.     kControlPageFlushAsync        = 7
  492. };
  493.  
  494. /* For ReleaseData*/
  495. typedef OptionBits ReleaseDataOptions;
  496.  
  497. enum {
  498.     kReleaseBackingStore        = 0x00000001
  499. };
  500.  
  501. /*  Message related declarations  */
  502. typedef UInt32 MessageType;
  503. /* Kernel Message Types*/
  504. #define kAllNonKernelMessageTypes    (SInt32)0x0FFFFFFF
  505. #define kAllMessages                (SInt32)0xFFFFFFFF
  506. /*    Options for CreatePort*/
  507. typedef OptionBits PortOptions;
  508. /*    Options for CreateObject*/
  509. typedef OptionBits ObjectOptions;
  510. /*    Options for LockObject*/
  511. typedef OptionBits ObjectLockOptions;
  512.  
  513. enum {
  514.     kLockObjectWithOneMessage    = 0x00000001
  515. };
  516.  
  517. /*    Options for SetObjectInformation;*/
  518. typedef OptionBits SetObjectOptions;
  519.  
  520. enum {
  521.     kSetObjectPort                = 0x00000002,
  522.     kSetObjectRefcon            = 0x00000004
  523. };
  524.  
  525. /*  Message System Options  */
  526. typedef OptionBits SendOptions;
  527.  
  528. enum {
  529.     kSendTransferKindMask        = 0x00000003,                    /* Set by sender*/
  530.     kSendByChoice                = 0x00000000,
  531.     kSendByReference            = 0x00000001,
  532.     kSendByValue                = 0x00000002,
  533.     kSendIsBuffered                = 0x00000003,
  534.     kSendIsPrivileged            = 0x00000008,                    /* Set by kernel*/
  535.     kSendIsAtomic                = 0x00000010,                    /* Set by sender*/
  536.     kSendPtrsAddressable        = 0x00000020,                    /* Set by kernel*/
  537.     kSendPtrsNeedAccessCheck    = 0x00000040                    /* Set by kernel*/
  538. };
  539.  
  540. typedef OptionBits ReceiveOptions;
  541.  
  542. enum {
  543.     kReceiveNoAddressTranslation = 0x00000002
  544. };
  545.  
  546. typedef OptionBits AcceptOptions;
  547.  
  548. enum {
  549.     kAcceptFunctionIsResident    = 0x00010000
  550. };
  551.  
  552. /*  Message Definition (Given to receiver or acceptor)  */
  553. struct MessageControlBlock {
  554.     MessageID                         message;
  555.     AddressSpaceID                     addressSpace;
  556.     KernelProcessID                 sendingKernelProcess;
  557.     TaskID                             sendingTask;
  558.     void *                            refcon;
  559.     SendOptions                     options;
  560.     MessageType                     theType;
  561.     LogicalAddress                     messageContents;
  562.     ByteCount                         messageContentsSize;
  563.     LogicalAddress                     replyBuffer;
  564.     ByteCount                         replyBufferSize;
  565.     OSStatus                         currentStatus;
  566.     UInt32                             reserved[4];
  567. };
  568. typedef struct MessageControlBlock MessageControlBlock;
  569.  
  570. typedef MessageControlBlock *MessageControlBlockPtr;
  571.  
  572. enum {
  573.     kMessageInformationVersion    = 1
  574. };
  575.  
  576. struct MessageInformation {
  577.     ObjectID                         object;
  578.     TaskID                             sendingTask;
  579.     KernelProcessID                 sendingKernelProcess;
  580. };
  581. typedef struct MessageInformation MessageInformation;
  582.  
  583. typedef MessageInformation *MessageInformationPtr;
  584. /*  Message Accept proc used to receive a message  */
  585. typedef OSStatus (*MessageAcceptProc)(const MessageControlBlock *message, void *acceptRefcon);
  586. /*    Version for GetPortInformation  */
  587.  
  588. enum {
  589.     kPortInformationVersion        = 1
  590. };
  591.  
  592. /*  Buffer used to return message port information  */
  593. struct PortInformation {
  594.     KernelProcessID                 owningKernelProcess;
  595.     MessageAcceptProc                 acceptProc;
  596.     ExceptionHandler                 acceptHandler;
  597.     AcceptOptions                     theAcceptOptions;
  598.     void *                            acceptRefcon;
  599.     ItemCount                         objectCount;
  600.     ItemCount                         pendingReceives;
  601.     ItemCount                         pendingSends;
  602.     ItemCount                         pendingReplies;
  603.     ItemCount                         transactionCount;
  604.     ItemCount                         blockedAsyncSenders;
  605.     ItemCount                         blockedAsyncReceivers;
  606. };
  607. typedef struct PortInformation PortInformation;
  608.  
  609. typedef PortInformation *PortInformationPtr;
  610. #endif
  611. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  612. /*  Tasks  */
  613. extern ExecutionLevel CurrentExecutionLevel(void );
  614.  
  615. extern TaskID CurrentTaskID(void );
  616.  
  617. extern OSStatus DelayFor(Duration delayDuration);
  618.  
  619. extern Boolean InPrivilegedMode(void );
  620.  
  621. /*  Software Interrupts  */
  622. extern OSStatus CreateSoftwareInterrupt(SoftwareInterruptHandler handler, TaskID task, void *p1, Boolean persistent, SoftwareInterruptID *theSoftwareInterrupt);
  623.  
  624. extern OSStatus SendSoftwareInterrupt(SoftwareInterruptID theSoftwareInterrupt, void *p2);
  625.  
  626. extern OSStatus DeleteSoftwareInterrupt(SoftwareInterruptID theSoftwareInterrupt);
  627.  
  628. extern void DisableSoftwareInterrupts(void );
  629.  
  630. extern void EnableSoftwareInterrupts(void );
  631.  
  632. extern Boolean InSoftwareInterruptHandler(void );
  633.  
  634. /*  Completion Routines  */
  635. extern void DisableCompletionRoutines(void );
  636.  
  637. extern void EnableCompletionRoutines(void );
  638.  
  639. /*  Secondary Interrupts  */
  640. extern OSStatus CallSecondaryInterruptHandler2(SecondaryInterruptHandler2 theHandler, ExceptionHandler exceptionHandler, void *p1, void *p2);
  641.  
  642. extern OSStatus QueueSecondaryInterruptHandler(SecondaryInterruptHandler2 theHandler, ExceptionHandler exceptionHandler, void *p1, void *p2);
  643.  
  644. /*  Timers  */
  645. extern OSStatus SetInterruptTimer(const AbsoluteTime *expirationTime, SecondaryInterruptHandler2 handler, void *p1, TimerID *theTimer);
  646.  
  647. extern OSStatus CancelTimer(TimerID theTimer, AbsoluteTime *timeRemaining);
  648.  
  649. /*  IO related Operations  */
  650. extern OSStatus PrepareMemoryForIO(IOPreparationTable *theIOPreparationTable);
  651.  
  652. extern OSStatus CheckpointIO(IOPreparationID theIOPreparation, IOCheckpointOptions options);
  653.  
  654. /*  Memory Operations  */
  655. extern OSStatus GetPageInformation(AddressSpaceID addressSpace, ConstLogicalAddress base, ItemCount requestedPages, PBVersion version, PageInformation *thePageInfo);
  656.  
  657. /*  Processor Cache Related  */
  658. extern OSStatus SetProcessorCacheMode(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, ProcessorCacheMode cacheMode);
  659.  
  660. #endif
  661. #if FOR_SYSTEM8_PREEMPTIVE
  662. /*  Queues  */
  663. extern OSStatus CreateKernelQueue(KernelQueueOptions options, KernelQueueID *theQueue);
  664.  
  665. extern OSStatus DeleteKernelQueue(KernelQueueID theQueue);
  666.  
  667. extern OSStatus WaitOnKernelQueue(KernelQueueID theQueue, void **p1, void **p2, void **p3, Duration timeOut);
  668.  
  669. extern OSStatus NotifyKernelQueue(KernelQueueID theQueue, void *p1, void *p2, void *p3);
  670.  
  671. extern OSStatus AdjustKernelQueueSIHLimit(KernelQueueID theQueue, SInt32 amount, ItemCount *newLimit);
  672.  
  673. /*  Event Flag Related Operations  */
  674. extern OSStatus CreateEventGroup(EventGroupID *theGroup);
  675.  
  676. extern OSStatus DeleteEventGroup(EventGroupID theGroup);
  677.  
  678. extern OSStatus SetEvents(EventGroupID theGroup, EventGroupMask mask);
  679.  
  680. extern OSStatus ClearEvents(EventGroupID theGroup, EventGroupMask mask);
  681.  
  682. extern OSStatus ReadEvents(EventGroupID theGroup, EventGroupMask *currentValue);
  683.  
  684. extern OSStatus WaitForEvents(EventGroupID theGroup, Duration timeOut, EventGroupMask mask, EventFlagOperation operation, EventGroupMask *value);
  685.  
  686. /*  KernelProcess Related Operations  */
  687. extern OSStatus CreateKernelProcess(KernelProcessName name, AddressSpaceID addressSpace, KernelProcessOptions options, KernelProcessID *theKernelProcess);
  688.  
  689. extern OSStatus ExitKernelProcess(TerminateOptions options, OSStatus exitStatus);
  690.  
  691. extern OSStatus DeleteKernelProcess(KernelProcessID theKernelProcess, TerminateOptions options, OSStatus deleteStatus);
  692.  
  693. extern OSStatus GetKernelProcessesInSystem(ItemCount requestedKernelProcesses, ItemCount *totalKernelProcesses, KernelProcessID *theKernelProcesses);
  694.  
  695. extern OSStatus GetKernelProcessInformation(KernelProcessID theKernelProcess, PBVersion version, KernelProcessInformation *kernelProcessInfo);
  696.  
  697. extern KernelProcessID CurrentKernelProcessID(void );
  698.  
  699. /*  Task Related Operations  */
  700. extern OSStatus CreateTask(TaskName name, KernelProcessID owningKernelProcess, TaskProc entryPoint, void *parameter, LogicalAddress stackBase, ByteCount stackSize, const KernelNotification *notification, TaskOptions options, TaskID *theTask);
  701.  
  702. extern OSStatus ExitTask(TerminateOptions options, OSStatus exitStatus);
  703.  
  704. extern OSStatus TerminateTask(TaskID theTask, TaskRelationship scope, TerminateOptions options, OSStatus terminateStatus);
  705.  
  706. extern ByteCount RemainingStackSpace(void );
  707.  
  708. extern OSStatus GetTaskInformation(TaskID theTask, PBVersion version, TaskInformation *taskInfo);
  709.  
  710. extern OSStatus SetTaskPriority(TaskID theTask, TaskRelationship scope, SetTaskPriorityOptions options);
  711.  
  712. extern OSStatus GetTasksInKernelProcess(KernelProcessID kernelProcess, ItemCount requestedTasks, ItemCount *totalTasks, TaskID *theTasks);
  713.  
  714. extern OSStatus AllocateTaskStorageIndex(TaskStorageIndex *theIndex);
  715.  
  716. extern OSStatus DeallocateTaskStorageIndex(TaskStorageIndex theIndex);
  717.  
  718. extern OSStatus SetTaskStorageValue(TaskStorageIndex theIndex, TaskStorageValue newValue);
  719.  
  720. extern TaskStorageValue GetTaskStorageValue(TaskStorageIndex theIndex);
  721.  
  722. /* Secondary Interrupt Handlers */
  723. extern OSStatus AdjustSecondaryInterruptHandlerLimit(SInt32 amount, ItemCount *newLimit);
  724.  
  725. /*  Timers  */
  726. extern OSStatus DelayUntil(const AbsoluteTime *expirationTime);
  727.  
  728. extern OSStatus SetTimer(const AbsoluteTime *expirationTime, const KernelNotification *notification, TimerOptions options, TimerID *theTimer);
  729.  
  730. extern OSStatus ResetTimer(TimerID theTimer, const AbsoluteTime *expirationTime, const KernelNotification *notification, TimerOptions options);
  731.  
  732. extern OSStatus AdjustInterruptTimerSIHLimit(SInt32 amount, ItemCount *newLimit);
  733.  
  734. /*  Address Space Management  */
  735. extern OSStatus CreateAddressSpace(AddressSpaceID *theAddressSpace);
  736.  
  737. extern OSStatus DeleteAddressSpace(AddressSpaceID theAddressSpace);
  738.  
  739. extern OSStatus GetAddressSpacesInSystem(ItemCount requestedAddressSpaces, ItemCount *totalAddressSpaces, AddressSpaceID *theAddressSpaces);
  740.  
  741. extern OSStatus GetSpaceInformation(AddressSpaceID theAddressSpace, PBVersion version, SpaceInformation *spaceInfo);
  742.  
  743. extern OSStatus InterspaceBlockCopy(AddressSpaceID sourceAddressSpace, AddressSpaceID targetAddressSpace, ConstLogicalAddress sourceBase, LogicalAddress targetBase, ByteCount length, InterspaceCopyOptions options);
  744.  
  745. extern OSStatus CheckUserAccess(ConstLogicalAddress address, ByteCount length, MemoryReferenceKind referenceKind);
  746.  
  747. extern AddressSpaceID CurrentAddressSpaceID(void );
  748.  
  749. /*  Area Management  */
  750. extern OSStatus CreateArea(KernelProcessID owningKernelProcess, BackingObjectID backingObject, const BackingAddress *backingBase, ByteCount backingLength, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel, ByteCount guardLength, AreaOptions options, LogicalAddress *areaBase, AreaID *theArea);
  751.  
  752. extern OSStatus CreateAreaForRange(KernelProcessID owningKernelProcess, AddressSpaceID otherSpace, ConstLogicalAddress otherBase, ByteCount length, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel, ByteCount guardLength, AreaOptions options, LogicalAddress *areaBase, AreaID *theArea);
  753.  
  754. extern OSStatus DeleteArea(AreaID theArea);
  755.  
  756. extern OSStatus GetAreaInformation(AreaID theArea, PBVersion version, AreaInformation *areaInfo);
  757.  
  758. extern OSStatus GetAreaFromAddress(AddressSpaceID addressSpace, ConstLogicalAddress address, AreaID *theArea);
  759.  
  760. extern OSStatus GetAreasInAddressSpace(AddressSpaceID addressSpace, ItemCount requestedAreas, ItemCount *totalAreas, AreaID *theAreas);
  761.  
  762. extern OSStatus SetAreaAccess(AreaID theArea, MemoryAccessLevel userAccessLevel, MemoryAccessLevel privilegedAccessLevel);
  763.  
  764. extern OSStatus SetAreaBackingBase(AreaID theArea, const BackingAddress *backingBase);
  765.  
  766. extern OSStatus CreateAreaReservation(KernelProcessID owningKernelProcess, LogicalAddress *reservationBase, ByteCount length, ReservationOptions options, AreaReservationID *theReservation);
  767.  
  768. extern OSStatus DeleteAreaReservation(AreaReservationID theReservation);
  769.  
  770. extern OSStatus GetReservationInformation(AreaReservationID theReservation, PBVersion version, ReservationInformation *reservationInfo);
  771.  
  772. extern OSStatus GetReservationsInAddressSpace(AddressSpaceID addressSpace, ItemCount requestedReservations, ItemCount *totalReservations, AreaReservationID *theReservations);
  773.  
  774. /*  Processor Cache Related  */
  775. extern OSStatus DataToCode(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length);
  776.  
  777. extern OSStatus FlushRange(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length);
  778.  
  779. /*  Paging control operations  */
  780. extern OSStatus ControlPagingForRange(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, PageControlOperation operation);
  781.  
  782. extern OSStatus ReleaseData(AddressSpaceID addressSpace, ConstLogicalAddress base, ByteCount length, ReleaseDataOptions options);
  783.  
  784. /*  Message Port Management  */
  785. extern OSStatus CreatePort(PortOptions options, PortID *thePort);
  786.  
  787. extern OSStatus DeletePort(PortID thePort);
  788.  
  789. extern OSStatus GetPortInformation(PortID thePort, PBVersion version, PortInformation *portInfo);
  790.  
  791. extern OSStatus GetPortsInSystem(ItemCount requestedPorts, ItemCount *totalPorts, PortID *thePorts);
  792.  
  793. /*  Message Object Management  */
  794. extern OSStatus CreateObject(PortID port, void *refcon, ObjectOptions options, ObjectID *theObject);
  795.  
  796. extern OSStatus DeleteObject(ObjectID theObject);
  797.  
  798. extern OSStatus LockObject(ObjectID theObject, ObjectLockOptions options, Duration timeOut);
  799.  
  800. extern OSStatus UnlockObject(ObjectID theObject);
  801.  
  802. extern OSStatus GetObjectInformation(ObjectID theObject, PortID *port, void **refcon);
  803.  
  804. extern OSStatus SetObjectInformation(ObjectID theObject, SetObjectOptions options, PortID port, void *refcon);
  805.  
  806. extern OSStatus GetObjectsInPort(PortID port, ItemCount requestedObjects, ItemCount *totalObjects, ObjectID *theObjects);
  807.  
  808. /*  Message Transaction Operations  */
  809. extern OSStatus SendMessageSync(ObjectID object, MessageType theType, ConstLogicalAddress messageContents, ByteCount messageContentsSize, LogicalAddress replyBuffer, ByteCount *replyBufferSize, SendOptions options, Duration timeOut);
  810.  
  811. extern OSStatus SendMessageAsync(ObjectID object, MessageType theType, ConstLogicalAddress messageContents, ByteCount messageContentsSize, LogicalAddress replyBuffer, ByteCount replyBufferSize, SendOptions options, const KernelNotification *notification, ByteCount *replySize, MessageID *theMessage);
  812.  
  813. extern OSStatus AcceptMessage(PortID port, MessageType theTypes, MessageAcceptProc acceptProc, ExceptionHandler theExceptionHandler, AcceptOptions options, void *acceptRefcon);
  814.  
  815. extern OSStatus ReceiveMessageSync(PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress buffer, ByteCount bufferSize, ReceiveOptions options, Duration timeOut);
  816.  
  817. extern OSStatus ReceiveMessageAsync(PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress buffer, ByteCount bufferSize, ReceiveOptions options, const KernelNotification *notification, ReceiveID *theReceive);
  818.  
  819. extern OSStatus ReplyToMessage(MessageID theMessage, OSStatus status, ConstLogicalAddress replyBuffer, ByteCount replyBufferSize);
  820.  
  821. extern OSStatus ReplyToMessageAndReceive(MessageID theMessage, OSStatus status, ConstLogicalAddress replyBuffer, ByteCount replyBufferSize, PortID port, MessageType theTypes, MessageControlBlock *theControlBlock, LogicalAddress receiveBuffer, ByteCount receiveBufferSize, ReceiveOptions options, Duration timeOut);
  822.  
  823. /*  Miscellaneous Messaging operations  */
  824. extern OSStatus CancelAsyncSend(MessageID theMessage);
  825.  
  826. extern OSStatus CancelAsyncReceive(ReceiveID theReceive);
  827.  
  828. extern OSStatus GetMessageInformation(MessageID theMessage, PBVersion version, MessageInformation *messageInfo);
  829.  
  830. /*  Miscellaneous System operations  */
  831. extern OSStatus GetSystemInformation(PBVersion version, SystemInformation *systemInfo);
  832.  
  833. /*    Notifications  */
  834. extern OSStatus DeliverKernelNotification(const KernelNotification *notification, OSStatus status);
  835.  
  836. #endif
  837. #if FOR_SYSTEM8_PREEMPTIVE
  838. /* These are defined in Memory for System 7 */
  839. extern pascal void BlockMove(const void *srcPtr, void *destPtr, long byteCount);
  840.  
  841. extern pascal void BlockMoveData(const void *srcPtr, void *destPtr, long byteCount);
  842.  
  843. extern void BlockMoveUncached(const void *srcPtr, void *destPtr, long byteCount);
  844.  
  845. extern void BlockMoveDataUncached(const void *srcPtr, void *destPtr, long byteCount);
  846.  
  847. extern void BlockZero(void *destPtr, long byteCount);
  848.  
  849. extern void BlockZeroUncached(void *destPtr, long byteCount);
  850.  
  851. #endif
  852.  
  853. #pragma options align=reset
  854. #endif /* PRAGMA_ALIGN_SUPPORTED */
  855.  
  856. #if PRAGMA_IMPORT_SUPPORTED
  857. #pragma import off
  858. #endif
  859.  
  860. #ifdef __cplusplus
  861. }
  862. #endif
  863.  
  864. #endif /* __KERNEL__ */
  865.  
  866.